<template>
  <div>
    <el-form
      class=""
      ref="form"
      label-width="100px"
      style="width: 600px"
      :model="form"
    >
      <el-form-item label="酒店名称" prop="hname">
        <el-input
          v-model="form.hname"
          placeholder="请输入酒店名称"
          :disabled="true"
        ></el-input>
      </el-form-item>
      <el-form-item label="酒店照片" prop="picture">
        <el-upload
          class="avatar-uploader"
          action="http://localhost:9000/upload"
          :on-success="handleAvatarSuccess"
          :show-file-list="false"
        >
          <img v-if="form.himg" :src="form.himg" class="avatar" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </el-form-item>
      <el-form-item label="到达日期" prop="arrdate">
        <el-input
          placeholder="请输入到达日期"
          v-model="form.arrdate"
          :disabled="true"
        ></el-input>
      </el-form-item>
      <el-form-item label="离开日期" prop="leavedate">
        <el-input
          :disabled="true"
          placeholder="请输入离开日期"
          v-model="form.leavedate"
        ></el-input>
      </el-form-item>
      <el-form-item label="订单金额" prop="oprice">
        <el-input
          placeholder="请输入订单金额"
          v-model="form.oprice"
          :disabled="true"
        >
          <template slot="append">元</template>
        </el-input>
      </el-form-item>
      <el-form-item label="酒店地址" prop="hlocation">
        <el-input
          :disabled="true"
          placeholder="请输入酒店地址"
          v-model="form.hlocation"
        ></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="fanhui">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        hid: '',
        hname: '',
        himg: '',
        hlocation: '',
        arrdate: '',
        leavedate: '',
        oprice: '',
      },
    }
  },

  mounted() {
    let params = { oid: this.$route.params.oid }
    this.$http.orderApi.query(params).then(res => {
      console.log(res)
      this.form.hid = res.data.data[0].hid
      this.form.arrdate = res.data.data[0].arrdate
      this.form.leavedate = res.data.data[0].leavedate
      this.form.oprice = res.data.data[0].oprice
      params = { hid: this.form.hid }
      this.$http.roomApi.query(params).then(res => {
        console.log(res)
        this.form.hname = res.data.data[0].hname
        this.form.himg = res.data.data[0].himg
        this.form.hlocation = res.data.data[0].hlocation
        console.log(this.form)
      })
    })
  },
  methods: {
    handleAvatarSuccess(res, file) {
      this.form.himg = res.data
    },
    fanhui() {
      this.$router.go(-1)
    },
  },
}
</script>

<style lang="scss" scoped>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 200px;
  height: 200px;
  line-height: 200px;
  text-align: center;
}
.avatar {
  width: 200px;
  height: 200px;
  display: block;
}
</style>
